package cn.xuqiudong.rabbitmq.config;

import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.context.annotation.Bean;

/**
 * 描述:
 *
 * @author Vic.xu
 * @since 2025-02-19 16:13
 */
public class MessageIdConfig {

    @Bean
    public Jackson2JsonMessageConverter jackson2JsonMessageConverter() {
        Jackson2JsonMessageConverter converter = new Jackson2JsonMessageConverter();
        // 开启自动生成消息 ID 的功能  用户识别不同的消息，也可以在业务中基于id判断是否重复消费消息
        converter.setCreateMessageIds(true);
        return converter;
    }
}
